package com.nbsaas.boot.store.rest.convert;

import com.nbsaas.boot.store.data.entity.StoreCatalog;
import com.nbsaas.boot.store.api.domain.response.StoreCatalogResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 门店分类-实体对象转化成响应对象
*/

public class StoreCatalogResponseConvert  implements Converter<StoreCatalogResponse,StoreCatalog> {

    @Override
    public StoreCatalogResponse convert(StoreCatalog source) {
        StoreCatalogResponse  result = new  StoreCatalogResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParent()!=null){
                        result.setParent(source.getParent().getId());
                    }
                    if(source.getShop()!=null){
                        result.setShop(source.getShop().getId());
                    }

                    try {
                        if(source.getShop()!=null){
                            result.setShopName(source.getShop().getName());
                        }
                    } catch (Exception ignored) { }

        return result;
    }

}

